<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="username" id="username"/>
    <input type="file" name="file1" id="file1"/>
    <button id="btn">提交</button>
</body>
<script>
    var btn = document.getElementById("btn");
    
    btn.onclick = function(){
        var file1 = document.getElementById("file1");
        //var username = document.getElementById("username");
        var formData = new FormData();
        formData.append("myimg",file1.files[0]);
        //formData.append("username",username.value);
        fetch('http://localhost:8081/upload',{
            method:"PUT",
            body:formData
        }).then(res=>{
            return res.text();
        }).then(res=>{
            console.log(res);
        })
    }
</script>
</html>